#include "measurementform.h"
#include "ui_measurementform.h"
#include <QPainter>
#include <QStyleOption>
#include <QToolBox>

MeasurementForm::MeasurementForm(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::MeasurementForm)
{
    ui->setupUi(this);
    this->setProperty("form","backgroundform");
    this->setFixedHeight(605);
    ui->leftBorderForm->SetLabelIcon("measurement");
}

MeasurementForm::~MeasurementForm()
{
    delete ui;
}

void MeasurementForm::UpdateShowType(int type)
{
    ui->leftBorderForm->UpdateShowType(type);
    ui->widget_measurementBasic->UpdateShowType(type);
}

void MeasurementForm::paintEvent(QPaintEvent *event)
{
    QStyleOption opt;
    opt.init(this);
    QPainter painter(this);
    style()->drawPrimitive(QStyle::PE_Widget,&opt,&painter,this);
    QWidget::paintEvent(event);
}

void MeasurementForm::on_toolButton_contractExpand_clicked(bool checked)
{
    // 查找widget_measurementBasic内部的toolBox并控制其显隐
    QToolBox *toolBox = ui->widget_measurementBasic->findChild<QToolBox*>("toolBox");
    if (toolBox) {
        toolBox->setHidden(!checked);
    }
    // 保持窗口高度设置逻辑不变
    if(checked)
        this->setFixedHeight(605);
    else
        this->setFixedHeight(100);
}
